package com.qingcheng.timer;

import com.qingcheng.service.OrderInfoSumService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

@Component
@Slf4j
public class OrderInfoSumTimer {

    @Autowired
    private OrderInfoSumService orderInfoSumService;

//     每天定时添加统计表任务
    @Scheduled(cron = "0 0 1 * * ?")
    public void createStatisticsRegular(){
        LocalDate date1=LocalDate.now();
        LocalDate date2= LocalDate.now().minusDays(1);
        LocalDate date3= LocalDate.now().minusDays(2);
        LocalDate date4= LocalDate.now().minusDays(7);
        orderInfoSumService.findOrderSum(date1.toString(),date2.toString(),date3.toString(),date4.toString());
    }

}
